Ext.define('BM.controller.Groups', {
    extend: 'Ext.app.Controller',
	views:  ['user.GroupList','user.GroupEdit'],
	stores: ['Groups'],
	models: ['Group'],
    init: function() {
         this.control({
            'grouplist': {
                itemdblclick: this.editUser
            },
            'groupedit button[action=save]': {
                click: this.updateToken
            }
        });
    },
    editUser: function(grid, record) {
    
        var view = Ext.widget('groupedit');
        view.down('form').loadRecord(record);
    },
    updateToken: function(button) {
        var win = button.up('window'),
        form   = win.down('form'),
        record = form.getRecord(),
        values = form.getValues();
	    record.set(values);
	    win.close();
    	this.getGroupsStore().sync();
    }
    
});